﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Graphics;

namespace Projeto__A_Cura.Scenes
{
    class Scene08 : BaseScene
    {
        public Scene08(SceneManager.Scenes thisScene)
            : base(thisScene) { }

        public override void LoadContent(ContentManager Content)
        {
            audio01 = Content.Load<Song>(contentDir + "D1");
            description = "Porta trancada";
        }

        public override void Update(
            KeyboardState keyboard,
            KeyboardState old_keyboard,
            GameTime gameTime,
            SceneManager.Scenes actualScene)
        {
            //keyboard = Keyboard.GetState();

            //if (actualScene == thisScene)
            //{
            if (!wasAudio01Played)
            {
                MediaPlayer.Play(audio01);
                wasAudio01Played = true;
            }

            if ((MediaPlayer.State == MediaState.Stopped)
                 || (SceneManager.DEBUG))
            {
                //if (keyboard.IsKeyDown(Keys.Space)&&!old_keyboard.IsKeyDown(Keys.Space))//repetir
                //{
                //    wasAudio01Played = false;
                //    SceneManager.actualScene = thisScene;
                //}

                //assim que tocar tudo volta logo para o estado anterior:
                SceneManager.actualScene = SceneManager.lastScene;
                //SceneManager.lastScene = thisScene;//fazer assim! nao depende de ordem
            }
        }

        //old_keyboard = keyboard;
    }
}
